package com.longteng.TestFour;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 12288 on 2021/5/24 11:37
 *
 * 物流
 */
public enum KehuType {

    VipPromotion("VIP", "VIP 客户", "vipPromotionService"),

    MemberPromotion("MEMBER", "会员", "memberPromotionService"),
    ClientPromotion("CLIENT", "普通客户", "clientPromotionService");

    /**
     * 代码
     */
    private String code;
    /**
     * 名称
     */
    private String name;

    private String serviceName;

    // 构造方法
    KehuType(String Code, String name, String serviceName ) {
        this.code = Code;
        this.name = name;
        this.serviceName = serviceName;
    }

    // 普通方法
    public static String getName(String code) {
        for (KehuType c : KehuType.values()) {
            if (c.code.equals(code)) {
                return c.name;
            }
        }
        return null;
    }

    // 普通方法
    public static String getServiceName(String code) {
        for (KehuType c : KehuType.values()) {
            if (c.code.equals(code)) {
                return c.serviceName;
            }
        }
        return null;
    }

    public static Map<String, String> getMap() {
        Map<String, String> map = new HashMap<String, String>();
        for (KehuType c : KehuType.values()) {
            map.put(c.getCode(), c.getName());
        }
        return map;
    }

    public static List<Map<String, String>> getList() {
        List list = new ArrayList();
        for (KehuType c : KehuType.values()) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("code", c.getCode());
            map.put("name", c.getName());
            list.add(map);
        }
        return list;
    }

    public static boolean contains(String code) {
        boolean include = false;
        for (KehuType e : KehuType.values()) {
            if (e.getCode().equals(code)) {
                include = true;
                break;
            }
        }
        return include;
    }

    public static KehuType getByCode(String code) {
        for (KehuType c : KehuType.values()) {
            if (c.code.equals(code)) {
                return c;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
